#define D2D_INPUT_COUNT 1
#define D2D_INPUT0_COMPLEX

#include "d2d1effecthelpers.hlsli"

float time =0;
//0水平光栅
int model = 0;
D2D_PS_ENTRY(main){

    float2 pos = D2DGetInputCoordinate(0).xy;
    int row =pos.y*30%30;
    int col =pos.x*30%30;

    float x = pos.x;
    float y = pos.y;

    if(model==0){
        if((row%2==0&&x<(1-time))||(row%2!=0&&x>time))
            return float4(0,0,0,0);
        x = row%2==0? x-(1-time):x+(1-time);
    }
    else if(model ==1){
         if((col%2==0&&y<(1-time))||(col%2!=0&&y>time))
               return float4(0,0,0,0);
        y = col%2==0? y-(1-time):y+(1-time);
    }
    else if(model ==2){
          if(time<frac(pos.y*30))
            return float4(0,0,0,0);
    }
    else if(model==3){
         if(time<frac(pos.x*30))
            return float4(0,0,0,0);
    }

   
    return D2DSampleInput(0,float2(x,y));
}

// set INCLUDEPATH="%WindowsSdkDir%\Include\%WindowsSDKVersion%\um"
//  fxc GratingEffect.hlsl /nologo /T lib_4_0_ps_only /D D2D_FUNCTION /D D2D_ENTRY=main /Fl GratingEffect.fxlib /I %INCLUDEPATH%
//  fxc GratingEffect.hlsl /nologo /T ps_4_0 /D D2D_FULL_SHADER /D D2D_ENTRY=main /E main /setprivate GratingEffect.fxlib /Fo:GratingEffect.bin /I %INCLUDEPATH%
// del GratingEffect.fxlib